home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: extensions&odf (for ODF team)
- Sent: 3/4/96 6:52 PM
- Received: 3/4/96 6:20 PM
- From: Greg Friedman, friedman@cognosis.com
- Reply-To: ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- Bernhard S. Wieser wrote:
-
- >So, let's see if this is acceptable to y'all ODF gurus...
- >
- >- I wrapped my sohproperty SOM thing in a derived ODExtension, call it XYZ
- >- I inserted the ...HasExtension, ...AcquireExtension, and ...Release
-
- Damon and Jim have already explained that ODF provides an extension manager
- class to simplify supporting the extension protocols. There are a couple
- of bugs in the d11 implementation of the extension manager, and a couple of
- non-obvious things you need to do in your extension.
-
- In ODF d11, FW_CExtensionManager::AcquireExtension incorrectly increments
- the reference count of every extension it returns. d11 also doesn't return
- the correct error if an extension that cannot be provided is requested. The
- corrected implementation of AcquireExtension is as follows:
-
- ODExtension* FW_CExtensionManager::AcquireExtension(Environment *ev, const
- char* name)
- {
- ODExtension* theExtension = (ODExtension
- *)fActiveExtensions.ValueAtKey(name);
-
- if (!theExtension)
- {
- CreateExtensionFunc func =
- (CreateExtensionFunc)fNameToCreateFuncMap.ValueAtKey(name);
- if (func)
- {
- theExtension = (func)(ev, fPart, name);
- if (theExtension)
- fActiveExtensions.AddPair(name,
- (void*)theExtension);
- }
- }
- else
- theExtension->Acquire(ev);
-
- if (!theExtension)
- FW_SetEvError(ev, kODErrUnsupportedExtension);
-
- return theExtension;
- }
-
- FW_CExtensionManager::ReleaseExtension also needs to return an environment
- error of kODErrUnsupportedExtension if the extension* wasn't provided by
- the part.
-
- When ODPart::ReleaseAll is called the BaseRemoved method of any existing
- extensions needs to be called. d11 does not implement this. It is fully
- implemented in ODF 1.
-
- Notes on implementing extensions:
-
- Make sure your extension has a uniquely named Init method. From your
- extension's Init method, be sure you call ODExtension::InitExtension. This
- will guarantee that your newly created extension begins life with a
- correctly initialized reference count.
-
- Make sure all of your extensions public methods call the IsValid method
- they inherit from ODExtension before attempting to do anything that
- requires referencing their base.
-
- ODExtension implements release as follows:
- Call the inherited ODRefCntObject::Release method. This will
- decrement the ref count
-
- If the base object is valid, and the refCount is zero, call the
- ReleaseExtension method of the base
-
- This mechanism does not automatically dispose the extension when the
- reference count drops to zero. Furthermore, it doesn't handle the case
- where your base has been removed and a release causes the extension's
- reference count to drop to zero. You will need to override Release in your
- extension to implement this functionality.
-
- Hope this helps...
-
- Greg Friedman
-
-
- ___________________________________________________________
- Greg Friedman ODF Engineering
- Apple Computer
-
-